import React, { Component } from 'react'
//导入 prop-types
import PropTypes from 'prop-types';

export default class PropsCom extends Component {
  //声明一个静态属性
  static propTypes = {
    name: PropTypes.string,
    age:  PropTypes.number.isRequired,
    gender: PropTypes.string
  }

  //为外部传入的属性进行默认值的设置
  static defaultProps = {  //default 默认的 props 属性
    age: 18
  }

  render() {
    //接收外部传入的数据
    return (
      <ul>
        <li>姓名: {this.props.name}</li>
        <li>年龄: {this.props.age}</li>
        <li>性别: {this.props.gender}</li>
      </ul>
    )
  }
}
